//
//  NSDate+YSExtension.h
//  YSKitExample
//
//  Created by Kyson on 2017/6/16.
//  Copyright © 2017年 YangShen. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSDateFormatter (YSExtension)

+ (instancetype)sharedDateFormatter;

@end

@interface NSDate (YSExtension)

#pragma mark - 日历
- (NSInteger)ys_year;

- (NSInteger)ys_month;

- (NSInteger)ys_day;

- (NSInteger)ys_hour;

- (NSInteger)ys_minute;

- (NSInteger)ys_second;

- (NSInteger)ys_nanosecond;

/**
 * 这一周中第几天,范围是从1－7
 */
- (NSInteger)ys_weekday;

/**
 * 本月的第几个星期几
 */
- (NSInteger)ys_weekdayOrdinal;

/**
 * 本月第几周
 */
- (NSInteger)ys_weekOfMonth;

/**
 * 本年第几周
 */
- (NSInteger)ys_weekOfYear;

/**
 * 时刻(1-4)
 */
- (NSInteger)ys_quarter;

/**
 * 判断该月是否为润月
 */
- (BOOL)ys_isLeapMonth;

/**
 * 判断该年是否为润年
 */
- (BOOL)ys_isLeapYear;

/**
 * 阴历年
 */
- (NSString *)ys_lunarYear;

/**
 * 生肖
 */
- (NSString *)ys_chineseZodial;

/**
 * 阴历月
 */
- (NSString *)ys_lunarMonth;

/**
 * 阴历日
 */
- (NSString *)ys_lunarDay;

/** 多长时间之后的时间 */
- (NSDate *)ys_dateByAddingYears:(NSInteger)years;
- (NSDate *)ys_dateByAddingMonths:(NSInteger)months;
- (NSDate *)ys_dateByAddingWeeks:(NSInteger)weeks;
- (NSDate *)ys_dateByAddingDays:(NSInteger)days;
- (NSDate *)ys_dateByAddingHours:(NSInteger)hours;
- (NSDate *)ys_dateByAddingMinutes:(NSInteger)minutes;
- (NSDate *)ys_dateByAddingSeconds:(NSInteger)seconds;

#pragma mark - Date -> String
+ (NSString *)ys_todayWithFormat:(NSString *)format;

/**
 * 通过格式字符串获得对应日期的字符串
 */
- (NSString *)ys_stringWithFormat:(NSString *)format;
- (NSString *)ys_stringWithFormat:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale;

/**
 * 返回一个ISO格式的时间字符串 "2010-07-09T16:13:30+12:00"
 */
- (NSString *)ys_stringWithISOFormat;

#pragma mark - String ---format---> Date
+ (NSDate *)ys_dateWithString:(NSString *)dateString format:(NSString *)format;
+ (NSDate *)ys_dateWithString:(NSString *)dateString format:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale;
+ (NSDate *)ys_dateWithISOFormatString:(NSString *)dateString;

#pragma mark - 日期格式化
/**
 * 是否是今年
 */
- (BOOL)ys_isThisYear;

/**
 * 是否是今天
 */
- (BOOL)ys_isToday;

/**
 * 是否是昨天
 */
- (BOOL)ys_isYesterday;

/**
 * 两个时间之间间隔
 */
+ (NSDateComponents *)ys_timeDifferenceComponentsFromDate:(NSDate *)startingDate toDate:(NSDate *)resultDate;

/**
 * 与当前时间的差距
 */
- (NSDateComponents *)ys_deltaWithNow;

/**
 *  格式化时间间隔
 */
+ (NSString *)ys_timeDifferenceStringFromDate:(NSDate *)startingDate toDate:(NSDate *)resultDate;

@end

